package org.gitman.filmBase.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.Properties;

import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JWindow;
import javax.swing.UIManager;

import org.apache.log4j.Logger;

import com.sun.awt.AWTUtilities;

public class InitScreen extends JWindow{
	
	Logger logger = Logger.getLogger(InitScreen.class);
	JProgressBar progressBar;
	
	public InitScreen(Properties properties){
		
		try {
			UIManager.setLookAndFeel(properties.getProperty("lookAndFeel"));
		} catch (Exception e) {
			logger.debug("Creating main appliaction Frame", e);
		} 
		//AWTUtilities.setWindowOpacity(this, 0.5f);
		
		int width = 378;
		int height = 349;
		setSize(width, height);
		Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
		setLocation((dim.width - width)/2, (dim.height - height)/2);
		setLayout(new BorderLayout());
		setBackground(new Color(0,0,0,0));
		ImagePanel imagePanel = new ImagePanel("initScreen2.jpg");
		
		add(imagePanel, BorderLayout.CENTER);

		
		JPanel progressPanel = new JPanel(new BorderLayout());
		progressPanel.setBackground(new Color(0,0,0,0));
		add(progressPanel, BorderLayout.SOUTH);
		progressBar = new JProgressBar();
		progressBar.setValue(0);
		progressBar.setMaximum(100);
		progressBar.setStringPainted(true);
		progressBar.setString("inicjalizacja");
		progressPanel.add(progressBar);
		progressPanel.setPreferredSize(new Dimension(320,40));
		
		
		setVisible(true);
	}

	public void setProgress(int val, String title){
		progressBar.setValue(val);
		progressBar.setString(title);
	}
}
